package com.heima.mapper;

import com.heima.pojo.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper {
    @Select("select * from weblogin.tb_user")
    List<User> findAll();

    @Insert("insert into weblogin.tb_user values (null,#{username},#{password})")
    void add(User user);

    @Delete("delete from weblogin.tb_user where id = #{id}")
    void delete(int id);

    @Update("update weblogin.tb_user set " +
            "username= #{username} , " +
            "password = #{password} " +
            "where id = #{id}"
    )
    void update(User user);

    @Select("select * from weblogin.tb_user where id = #{id}")
    User findById(int id);
}
